package data;

import ihm.popupAlerte;

import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JOptionPane;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.AbstractTableModel;

import network.Connexion;


public class ModeleListeAlertes implements Observer{
	ListeAlertes listalertes;
	
	public ModeleListeAlertes()
	{
		super();
	}
	
	@Override
	public void update(Observable arg0, Object arg1){
		listalertes = (ListeAlertes) arg0;
		int count;
		//File fichier1 = new File(listalertes.get(0).getCheminAlerte());
		
		//OuvrirFile(fichier1); 
		for(count =0;count<listalertes.size();count++)
		{
			popupAlerte p1 = new popupAlerte(listalertes.get(count).getLabelAlerte());
			p1.setVisible(true);
		}
	}
	
	public boolean OuvrirFile(final File file) 
	{
		  if (!Desktop.isDesktopSupported()) {
		    return false;
		  }

		  Desktop desktop = Desktop.getDesktop();
		  if (!desktop.isSupported(Desktop.Action.OPEN)) {
		    return false;
		  }

		  try {
		    desktop.open(file);
		  } catch (IOException e) {
		    // Log an error
		    return false;
		  }

		  return true;
	}
	
}
